import { createTransport } from "nodemailer";
import { weathertemplate,hotWater } from './template'
const user = 'keke7426e@163.com'
const pass = 'AGPFUXIMXWUYRZQE'
const smtpTransport = createTransport({
  host: 'smtp.163.com',//pop、smtp、imap
  port: 465,
  secure: true,
  auth: {
    user,pass
  }
})

export const sendMail = ({to,title,text,templateconf}) => {
  const name = '一柯小白菜菜菜'
  return smtpTransport.sendMail({
    from: `${name} <${user}>`,
    to,
    subject:title,
    text,
    html:weathertemplate(templateconf),
  })
}

export const sendHotWater = ({to,title,text,templateconf}) => {
  const name = '女仆的定时服务'
  return smtpTransport.sendMail({
    from: `${name} <${user}>`,
    to,
    subject:title,
    text,
    html:hotWater(templateconf),
  })
}